package com.bilibili.bilibili.application;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.tencent.bugly.crashreport.CrashReport;

import cn.jpush.android.api.JPushInterface;


/**
 * 作者：郭传沛 on 2017/3/9 08:00
 * 邮箱：bestyourselfgcp@163.com
 * 类用途:
 */

public class App extends Application {

    private static Context mContext;
    private static RequestQueue mQueue;
    public static SharedPreferences mSharedPreferences;
    public static SharedPreferences.Editor mEdit;

    @Override
    public void onCreate() {
        super.onCreate();
        //极光推送初始化
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        mContext = getApplicationContext();
        mQueue = Volley.newRequestQueue(getApplicationContext());
        //Bugly初始化
        CrashReport.initCrashReport(getApplicationContext(), "63248c3100", true);
        //记录登录状态的Boolean值
        mSharedPreferences = getSharedPreferences("boolean", MODE_PRIVATE);
        boolean tag = mSharedPreferences.getBoolean("tag", false);
        mEdit = mSharedPreferences.edit();
        mEdit.putBoolean("tag", tag);
        mEdit.commit();
    }

    //定义全局上下文
    public static Context getContext() {
        return mContext;
    }

    //Volley请求队列
    public static RequestQueue getHttpQueue() {
        return mQueue;
    }
}
